<template>
  <header>
    <div class="l-content">
      <div>
        <el-button
          @click="handleMenu"
          icon="el-icon-menu"
          size="mini"
        ></el-button>
      </div>
      <div>
        <h3 style="color: #fff">
          <el-breadcrumb separator="/">
            <el-breadcrumb-item class="mbx" v-for="item in tags" :key="item.path" :to="{ path: item.path }">{{
              item.label
            }}</el-breadcrumb-item>
          </el-breadcrumb>
        </h3>
      </div>
    </div>
    <div class="r-content">
      <el-dropdown @command="handleClick" trigger="click" size="mini">
        <span class="el-dropdown-link">
          <img :src="usetImg" alt="" />
        </span>
        <el-dropdown-menu slot="dropdown">
          <el-dropdown-item>个人中心</el-dropdown-item>
          <el-dropdown-item command="cancel">退出</el-dropdown-item>
        </el-dropdown-menu>
      </el-dropdown>
    </div>
  </header>
</template>

<script>
import { mapState } from "vuex";
import Cookie from "js-cookie";
export default {
  name: "CommonHeader",
  data() {
    return {
      usetImg: require("../assets/logo.png"),
    };
  },
  methods: {
    handleMenu() {
      this.$store.commit("collapseMenu");
    },
    handleClick(command) {
      if (command === "cancel") {
        console.log('登出');
        Cookie.remove("token");
        Cookie.remove("menu");
        this.$router.push("/login");
      }
    },
  },
  computed: {
    ...mapState({
      tags: (state) => state.tab.tabsList,
    }),
  },
};
</script>

<style scoped>
.l-content {
  display: flex;
  align-items: center;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
}
img {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: rgb(82, 82, 174);
}
.el-button {
  margin-right: 20px;
}
.el-breadcrumb ::v-deep .el-breadcrumb__inner {
  color: #fff !important
}
</style>